package com.anzym.android.kegdroiddisplay;

import android.content.Context;
import android.graphics.Canvas;
import android.util.Log;
import android.view.View;

public class MyView extends View {

	private String TAG = "MyView";
	
	private int viewWidth;
    private int viewHeight;
    private boolean droidsNotSet = true;
    private KegDroidMapFragment kdFrag;


	public MyView(Context context, KegDroidMapFragment kegDroidMapFragment) {
		super(context);
		kdFrag = kegDroidMapFragment;
		
		// TODO Auto-generated constructor stub
	}
	
	@Override
    protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld){
            super.onSizeChanged(xNew, yNew, xOld, yOld);
            viewWidth = xNew;
            viewHeight = yNew;
    }

	public int getViewWidth() {
		return viewWidth;
	}

	public void setViewWidth(int viewWidth) {
		this.viewWidth = viewWidth;
	}

	public int getViewHeight() {
		return viewHeight;
	}

	public void setViewHeight(int viewHeight) {
		this.viewHeight = viewHeight;
	}
	
	@Override
    protected void onDraw(Canvas canvas){
            super.onDraw(canvas);
            /*
            finally, once the view gets drawn on to the screen
            we can retrieve the dimension values
            as stored in the global variables declared above
            */
            String msg = "width: " + viewWidth + "height: " + viewHeight;
            //Log.d(TAG, msg);
            //Do this only once.
            if (droidsNotSet) {
                kdFrag.setDroids(viewHeight, viewWidth);
                droidsNotSet = false;
            }
            //System.out.println(msg);
    }

}
